//
//  BCZMainViewController.swift
//  BCZWeibo
//
//  Created by 鲍超志 on 16/8/9.
//  Copyright © 2016年 leo. All rights reserved.
//

import UIKit

class BCZMainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        
        //首页
        addChildViewController(BCZHomeViewController(), title: "首页", imgName: "tabbar_home")
        
        //消息
        addChildViewController(BCZMessageViewController(), title: "消息", imgName: "tabbar_message_center")
        
        //发现
        addChildViewController(BCZDiscoveryViewController(), title: "发现", imgName: "tabbar_discover")
        
        //我
        addChildViewController(BCZProfileViewController(), title: "我的", imgName: "tabbar_profile")
    }
    
    //添加子控制器
    func addChildViewController(vc: UIViewController,title:String,imgName:String) {
        
        vc.title = title
        vc.tabBarItem.image = UIImage(named: imgName)
        vc.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName:UIColor.orangeColor()], forState: UIControlState.Selected)
        //设置图片渲染颜色
        vc.tabBarItem.selectedImage = UIImage(named: "\(imgName)_selected")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        
        //添加子控制器
        addChildViewController(UINavigationController.init(rootViewController: vc))
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    
}
